//
//  RefundInfoTableViewCell.m
//  jingdongfang
//
//  Created by MTiMac02 on 2018/1/16.
//  Copyright © 2018年 LJL. All rights reserved.
//

#import "RefundInfoTableViewCell.h"
#import "IWTextView.h"

@interface RefundInfoTableViewCell ()
{
    UITextView *reasonView;
    UILabel *refundTime;
    UILabel *refundSort;
    UILabel *refundSortDetail;
    UILabel *refundReason;
    UILabel *refundReasonDetail;
    UILabel *refundMoney;
    UILabel *refundMoneyDetail;
    UILabel *refundExplain;
    UILabel *refundExplainDetail;
}

@end
@implementation RefundInfoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}
- (void)createUI {
    self.contentView.backgroundColor = [UIColor c3Color];
    //退款时间;
    refundTime = [[UILabel alloc] initWithFrame:CGRectZero];
    refundTime.font = [UIFont font13];
    [refundTime sizeToFit];
    refundTime.textColor = [UIColor c5Color];
    [self.contentView addSubview:refundTime];
    //退款类别
    refundSort=[[UILabel alloc]initWithFrame:CGRectZero];
    refundSort.font=[UIFont font13];
    refundSort.textColor=[UIColor c5Color];
    [self addSubview:refundSort];
    refundSortDetail=[[UILabel alloc]initWithFrame:CGRectZero];
    refundSortDetail.font=[UIFont font13];
    refundSortDetail.textColor=[UIColor c5Color];
    [self.contentView addSubview:refundSortDetail];
    //退款原因
    refundReason=[[UILabel alloc]initWithFrame:CGRectZero];
    refundReason.font=[UIFont font13];
    refundReason.textColor=[UIColor c5Color];
    [self.contentView addSubview:refundReason];
    refundReasonDetail=[[UILabel alloc]initWithFrame:CGRectZero];
    refundReasonDetail.font=[UIFont font13];
    refundReasonDetail.textColor=[UIColor c5Color];
    [self.contentView addSubview:refundReasonDetail];
    //退款金额
    refundMoney=[[UILabel alloc]initWithFrame:CGRectZero];
    refundMoney.font=[UIFont font13];
    refundMoney.textColor=[UIColor c5Color];
    [self.contentView addSubview:refundMoney];
    refundMoneyDetail=[[UILabel alloc]initWithFrame:CGRectZero];
    refundMoneyDetail.font=[UIFont font13];
    refundMoneyDetail.textColor=[UIColor c5Color];
    [self.contentView addSubview:refundMoneyDetail];
    //退款说明
   refundExplain=[[UILabel alloc]initWithFrame:CGRectZero];
    refundExplain.font=[UIFont font13];
    refundExplain.textColor=[UIColor c5Color];
    [self.contentView addSubview:refundExplain];
    
    refundExplainDetail=[[UILabel alloc]initWithFrame:CGRectZero];
    refundExplainDetail.font=[UIFont font13];
    refundExplainDetail.textColor=[UIColor c5Color];
    refundExplainDetail.width=KSCREENWIDTH-refundExplain.width-50;
    refundExplainDetail.height=35;
    [refundExplainDetail setLineBreakMode:NSLineBreakByClipping];
    [refundExplainDetail setNumberOfLines:0];
    [self.contentView addSubview:refundExplainDetail];
}
-(void)layoutSubviews{
    [super layoutSubviews];
    refundTime.text=self.refundInfomation.requestTime;
    [refundTime sizeToFit];
    //退款类别
    refundSort.text=NSLocalizedString(@"Refund Category:", nil);
    [refundSort sizeToFit];
    refundSortDetail.font=[UIFont font13];
    if ([self.refundInfomation.state integerValue]==1) {
        refundSortDetail.text=NSLocalizedString(@"Refund Only", nil);
    }else if ([self.refundInfomation.state integerValue]==2){
        refundSortDetail.text=NSLocalizedString(@"Refund & Return", nil);
    }
    [refundSortDetail sizeToFit];
    //退款原因
    refundReason.text=NSLocalizedString(@"Refund Reason(s):", nil);
    [refundReason sizeToFit];
    if ([self.refundInfomation.content integerValue]==1) {
        refundReasonDetail.text=NSLocalizedString(@"I Don't Like it./I Don't Want It", nil);
    }else if ([self.refundInfomation.content integerValue]==2) {
        refundReasonDetail.text=NSLocalizedString(@"Information Filling Error/Bidding Error", nil);
    }else if ([self.refundInfomation.content integerValue]==3) {
        refundReasonDetail.text=NSLocalizedString(@"Goods and Description Not Matched", nil);
    }else if ([self.refundInfomation.content integerValue]==4) {
        refundReasonDetail.text=NSLocalizedString(@"Flawed/Damaged", nil);
    }
    [refundReasonDetail sizeToFit];
    //退款金额
    refundMoney.text=NSLocalizedString(@"Refund Amount:", nil);
    [refundMoney sizeToFit];
    refundMoneyDetail.text=[NSString stringWithFormat:@"¥%@",self.refundInfomation.price.length>0?self.refundInfomation.price:@"0.00"];
    [refundMoneyDetail sizeToFit];
    //退款说明
    refundExplain.text=NSLocalizedString(@"Refund Description:", nil);
    [refundExplain sizeToFit];
    [refundExplainDetail setContentMode:UIViewContentModeTop];
    refundExplainDetail.text=self.refundInfomation.reason.length>0?self.refundInfomation.reason:@"";
    [refundExplainDetail sizeToFit];
    refundExplainDetail.width=KSCREENWIDTH-refundExplain.width-50;
    refundExplainDetail.height=35;
    [refundExplainDetail setLineBreakMode:NSLineBreakByClipping];
    [refundExplainDetail setNumberOfLines:0];
    refundExplainDetail.text = [self.refundInfomation.reason stringByAppendingString:@"\n "];
    refundTime.x=15;
    refundTime.y=5;
    refundSort.x=refundTime.x;
    refundSort.y=refundTime.bottom+3;
    refundSortDetail.x=refundSort.right+3;
    refundSortDetail.y=refundSort.y;
    refundReason.x=refundTime.x;
    refundReason.y=refundSort.bottom+3;
    refundReasonDetail.x=refundReason.right+3;
    refundReasonDetail.y=refundSortDetail.bottom+3;
    refundMoney.x=refundReason.x;
    refundMoney.y=refundReason.bottom+3;
    refundMoneyDetail.x=refundMoney.right+3;
    refundMoneyDetail.y=refundReason.bottom+3;
    refundExplain.x=refundMoney.x;
    refundExplain.y=refundMoney.bottom+3;
    refundExplainDetail.x=refundExplain.right+3;
    refundExplainDetail.y=refundExplain.y-2;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
